%{
	business.BackstageSet  currBackstageSet = business.BackstageSet.getCurrentBackstageSet();
}%
#{extends 'common/frontMain.html' /} #{set title:currBackstageSet.seoTitle +' | 我的账户 | 站内信 | 发件箱' /}

<!-- 内容区域 start -->
<div class="xf_con_box">
	<div class="xf_con_mem_nav"></div>
	<!-- 左边导航区域 -->
	#{include "front/account/AccountHome/homeLeft.control"/}

	<!-- 右侧内容区域 -->
	<!-- 我的站内信 -->
	<div class="xf_con_mem_r_content" id="mymessages">
		<div id="msglist" class="xf_con_wyjk_tentultbody">
			<div class="xf_mem_zhannx_tab">
			<!-- 搜索区域 -->
			<ul class="xf_membill_search clr">
				<li class="xf_membill_searchLi"><span class="xf_membill_segjc">标题：</span>
					<input type="text" value="${pageBean.conditions.keyword}" placeholder="标题"
					id="xf_membill_shurk_yhm" class="xf_membill_shurk_yhm" /></li>
				<li><input type="button" value="搜 索"
					class="xf_membill_button_yhm xf_membill_button_yhm2"
					onclick="search();"></li>
			</ul>
		
			<table border="0" cellpadding="0" cellspacing="0" width="739"
				class="xf_mem_znx_viewcpms">
				<tr>
					<th><input type="checkbox" name="check_all" onclick="checkAll()" value="-1"/></th>
					<th>序号</th>
					<th>收件人</th>
					<th>标题</th>
					<th>发送时间</th>
					<th>操作</th>
				</tr>
		
				#{list pageBean.page, as:'msg'}
				<tr>
					<td><input type="checkbox" class="xf_mem_znx_wdtr_checkbox" name="check_box" value="${msg.id}">
					</td>
					<td>${msg_index}</td>
					<td>${msg?.receiver_name}</td>
					<td>${msg?.title}</td>
					<td>${msg?.time?.format("yyyy-MM-dd HH:mm:ss")}</td>
					<td>
						<span style="cursor: pointer;" onclick="outboxMsgDetail(${msg_index} + ${pageBean.pageSize} * (${pageBean.currPage} - 1));">查看</span>
					</td>
				</tr>
				#{/list}
		
			</table>
			<div class="xf_mem_znx_cc">
				<span class="xf_accout_cont_imginput" onclick="deleteOutboxMsgs()">删除</span>
			</div>
		
		
			<!-- 分页器 -->
			<div class="xf_wylc_page xf_zqzr_view_page1 xf_znx_view_page1">
				#{page currPage:pageBean.currPage,pageSize:pageBean.pageSize,totalCount:pageBean.totalCount,theme:1,style:2}
					keyword=${pageBean.conditions.keyword}
				#{/page}
			</div>
		</div>
		</div>
		<div id="detail" class="xf_con_wyjk_tentultbody"></div>

	</div>
	<!-- 清除浮动 -->
	<div class="clear"></div>
</div>
<!-- 内容区域 end -->

<script type="text/javascript" src="@{'/public/javascripts/tab/tab_usr.js'}"></script>
<script type="text/javascript">
	var g_index = 1;
	
	$(function() {
		/* 高亮显示 */
		showHighLightFront(4);
		showHighLightFront2(7, 2);
	});

	function outboxMsgDetail(index) {
		g_index = index;
	
		$.ajax({
			url : "@{outboxMsgDetail()}",
			type : "POST",
			data : {
				"index" : index,
				"keyword" : $("#xf_membill_shurk_yhm").val(),
				"readStatus" : $("#read_status").val()
			},
			success : function(data) {
				if (data.code < 0) {
					alert(data.msg);
					
					return;
				}
				
				$("#detail").html(data).show();
				$("#msglist").hide();
			},
			error : function() {
				alert("对不起，出现错误!");
			}
		});
	}
	
	function deleteOutboxMsgs() {
		var arr = new Array();

		$('input:checkbox[name=check_box]:checked').each(function(){
			arr.push($(this).val());
		});
		
		var ids = arr.join(",");
		
		if (ids == "") {
			alert("请选择要删除的信息!");
			return;
		}
		
		if (!confirm("确认要删除？")) {
            return;
        }
		
		$.ajax({
			url : "@{deleteOutboxMsgs()}",
			type : "POST",
			data : {
				"ids" : ids
			},
			success : function(data) {
				if (data.code < 0) {
					alert(data.msg);
					
					return;
				}
				
				location.reload();				
			},
			error : function() {
				alert("对不起，出现错误!");
			}
		});
		
	}

	function search() {
		window.location.href = "@{front.account.Message.outboxMsgs()}?keyword=" + encodeURIComponent($("#xf_membill_shurk_yhm").val());
	}
</script>
